<template>
	<view class="wrap">
		<u-card class="task-list-item" :show-head="false" :border="true" padding="36" margin="24rpx"
			:head-border-bottom="false">
			<view slot="body">
				<u-row gutter="16" style="gap:24rpx">
					<u-col span="12">
						<view class="apply-text"><span>区域巡检单号：</span>{{this.checkOrder}}</view>
					</u-col>
					<u-col span="12">
						<view class="apply-text"><span>巡检时间：</span>{{this.checkTime}}</view>
					</u-col>
					<u-col span="12">
						<view class="apply-text"><span>巡检人：</span>{{this.checkPerson}}</view>
					</u-col>
				</u-row>
			</view>
		</u-card>
		<view>
			<!-- <u-line color="black" :hair-line="false" /> -->
			<view>
				<text style="color: cornflowerblue;font-size: x-large; margin-left: 20rpx;">巡检结果</text>
			</view>
			<view>
				<u-card class="task-list-item" :show-head="false" :border="true" padding="36" margin="24rpx"
					:head-border-bottom="false">
					<view slot="body">
						<u-row gutter="0" style="gap:24rpx">
							<u-col span="12">
								<view class="apply-text"><span>巡检水厂：</span>{{this.strucName}}</view>
							</u-col>
						</u-row>
					</view>
				</u-card>
			</view>
			<u-card v-for="item in orderResult" :key="item.id" class="task-list-item" :show-head="false" :border="true"
				padding="20" margin="20rpx" :head-border-bottom="false">
				<view class="resultBody" slot="body">
					<u-row gutter="16">
						<u-col span="12">
							<view class="apply-text"><text>{{item.item_name}}</text></view>
						</u-col>
						<u-col span="12" class="rowBody">
							<view class="apply-text item" v-if="item.newData['项目'+item.id]">
								<label class="radio">
									<radio disabled style="transform:scale(0.7)" value="r1"
										:checked="item.newData['项目'+item.id]==1" />合格
								</label>
								<label class="radio">
									<radio color="red" disabled style="transform:scale(0.7)" value="r2"
										:checked="item.newData['项目'+item.id]==0" />不合格
								</label>
							</view>
							<view class="apply-text item" v-else-if="item.newData['备注'+item.id]==''">
								<label class="radio">
									<radio disabled style="transform:scale(0.7)" value="r1" :checked="false" />合格
								</label>
								<label class="radio">
									<radio disabled style="transform:scale(0.7)" value="r2" :checked="false" />不合格
								</label>
							</view>
							<view class="apply-text item"><span>备注：</span><text>{{item.newData['备注'+item.id]}}</text>
							</view>
						</u-col>
					</u-row>
				</view>
			</u-card>
		</view>

	</view>
</template>
<script>
	export default {
		data() {
			return {
				orderId: null,
				orderInfo: null,
				orderResult: [],
				orderItems: null,
				checkOrder: "",
				checkTime: "",
				checkPerson: "",
				strucName: "",
			}
		},
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			this.orderId = option.id;
			this.getGDDetail()
		},
		methods: {
			//获取id，查询出工单详情
			getGDDetail() {
				this.$u.api.findQYXJGDDetail({
						"algorithmProcessId": "inspection_work_order_details",
						"param": {
							"data": {
								"id": this.orderId
							}
						}
					})
					.then(res => {
						let orderInfos = res.data.data.result || [];
						this.orderResult = orderInfos.items
						this.orderInfo = orderInfos;
						this.checkOrder = this.orderInfo.inspection_code;
						this.checkTime = this.orderInfo.inspection_date;
						this.checkPerson = this.orderInfo.nice_name;
						this.strucName = this.orderInfo.structure_name;
						let resultData = JSON.parse(orderInfos.inspection_result)


						for (var i = 0; i < this.orderResult.length; i++) {
							if (resultData != null) {
								for (var j = 0; j < resultData.length; j++) {
									var key = '项目' + this.orderResult[i].id;
									if (resultData[j].hasOwnProperty(key)) {
										this.orderResult[i].newData = resultData[j];
										break;
									}
								}
							}
							if (!this.orderResult[i].hasOwnProperty('newData')) {
								this.orderResult[i].newData = {
									[key]: "",
									['备注' + this.orderResult[i].id]: ""
								};
							}
						}
						this.orderItems = resultData
						console.log("结果", this.orderResult);
						console.log("结果1", resultData);

					});
			}
		},
	}
</script>
<style lang="scss" scoped>
	page {
		background-color: #fff;
	}

	.wrap .search {
		background: #ffffff;
	}

	.uni-title {
		font-size: 30rpx;
		color: #333333;
		padding: 10px;
		background: #fff;
		border-top: 1px solid #ededed;
		margin-top: 20rpx;
	}

	.uni-media-list {
		padding: 15px 15px;

	}

	.uni-media-list-body {
		height: 42px;
		padding-left: 20rpx;
	}

	.uni-media-list-text-top {
		height: 40rpx;
		overflow: hidden;
		width: 100%;
		line-height: 40rpx;
		font-size: 32rpx;
		display: flex;
		justify-content: space-between;
	}

	.uni-media-list-text-bottom {
		width: 100%;
		line-height: 24rpx;
		font-size: 26rpx;
		color: #666666;

		span {
			margin-right: 10rpx;
		}
	}


	.head-text {
		font-size: 32rpx;
		font-weight: bold;
		color: #333333;
		padding: 30rpx 0;
		margin-left: 24rpx;
	}



	.grid {
		background-color: #fff;
		border-radius: 20rpx;
		padding: 24rpx;

		.grid-text {
			font-size: 28rpx;
			margin-top: 28rpx;
			color: $u-type-info;
			// color: #333;
			font-weight: bold;
		}

	}

	.charts-box {
		width: 100%;
		height: 600rpx;
		background-color: #fff;
		border-radius: 20rpx;
		padding: 24rpx;
	}

	.apply-text {
		font-size: 28rpx;
		color: #333333;
		height: 50rpx;

		span {
			color: #999999;
		}
	}


	.apply-list-foot {
		font-size: 28rpx;
	}


	.searchButton {
		height: 50rpx;
	}

	.selectCondition {

		.search {
			display: inline-block;
			width: 300rpx;

		}

		.selectItem {
			display: contents;
		}

	}

	.wrap .navProgramm {
		white-space: nowrap;

		.item {
			width: 50%;
			height: 220rpx;
			display: inline-block;
			margin-right: 10rpx;
		}
	}

	.rowBody {
		display: flex;
		justify-content: space-between;

		.item {
			flex: 1;
			// text-align: center;
		}
	}

	.task-list-item {
		box-shadow: 4rpx -4rpx 6rpx rgba(0, 0, 0, 0.1) !important;
	}
</style>